setwd("/home1/30/jc227089/Quoll_model/PBS_files")


script.file<-"/home1/30/jc227089/evo-dispersal/Quoll_model/PVA.R"

ii<-1:10
for(j in 1:length(ii)){
	##create the sh file
	zz = file(paste('QuollPVA', ii[j], '.sh', sep=''),'w')
		cat('##################################\n',file=zz)
		cat('#!/bin/sh\n',file=zz)
		cat('cd $PBS_O_WORKDIR\n',file=zz)
		cat("R CMD BATCH --no-restore --no-save '--args sr=10 file.ID=", ii[j], "' " ,script.file, " QuollPVA",ii[j],".Rout \n",sep="",file=zz)
		cat('##################################\n',file=zz)
	close(zz)			
	#submit the job
	system(paste("qsub -m n QuollPVA", ii[j], ".sh", sep=""))
}